<?php
$params = array_merge(
    require __DIR__ . '/../../common/config/params.php',
    require __DIR__ . '/params.php'
);

$config=  [
    'id' => 'app-api',
    'basePath' => dirname(__DIR__),
    'controllerNamespace' => 'api\controllers',
//    'defaultRoute'        => 'site/index',
    'bootstrap' => ['log'],
    'modules' => [
        'v1' => [
            'class' => 'api\modules\v1\Module',
        ],
    ],
    'components' => [
        'request' => [
            'csrfParam' => '_csrf-api',
            // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
            'cookieValidationKey' => 'VPYrKtfa1f0Pm950L2v2JxTjHz0BYmGR',
            'parsers'              => [
                'application/json' => 'yii\web\JsonParser',
                'text/json'        => 'yii\web\JsonParser',
            ],
        ],
        'user' => [
            'identityClass' => 'common\models\User',
            'enableAutoLogin' => true,
            'identityCookie' => ['name' => '_identity-api', 'httpOnly' => true],
        ],
        'session' => [
            // this is the name of the session cookie used for login on the api
            'name' => 'advanced-api',
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
        'urlManager' => [
            'enablePrettyUrl' => true,  //true：美化的url，可以去掉?r=
            'showScriptName' => false, //false：隐藏index.php
            'suffix' => '', //后缀，如果设置了此项.html，那么浏览器地址栏就必须带上.html后缀（加载控制器方法的后面），否则会报404错误
            'rules' => [
            ],
        ],

    ],
    'params' => $params,
];

if (YII_ENV_DEV) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = [
        'class' => 'yii\debug\Module',
        'allowedHosts'=>['*'],
        'allowedIPs'    => ['*'],
    ];

    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = [
        'class' => 'yii\gii\Module',
        'allowedIPs'    => ['*'],
//        'controllerMap' => [
//            'default' => [
//                'class'  => 'yii\gii\controllers\DefaultController',
//                'layout' => 'generator',
//            ],
//        ],
//        'generators'    => [
//            'common-model'  => [
//                'class' => 'zkc\gii\generators\commonmodel\Generator',
//                'name'  => '公共模型生成',
//            ],
//            'easyui-module' => ['class' => 'zkc\gii\generators\module\Generator'],
//            'easyui-model'  => ['class' => 'zkc\gii\generators\model\Generator'],
//            'easyui-crud'   => ['class' => 'zkc\gii\generators\crud\Generator'],
//        ],
    ];
}

return $config;

